/**

 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.github.cakin.shiro.chapter22.jcaptcha;

import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;

/**
 * @className: MyManageableImageCaptchaService
 * @description: 提供了判断仓库中是否有相应的验证码存在
 * @date: 2020/5/30
 * @author: cakin
 */
public class MyManageableImageCaptchaService extends DefaultManageableImageCaptchaService {

    public MyManageableImageCaptchaService(com.octo.captcha.service.captchastore.CaptchaStore captchaStore, com.octo.captcha.engine.CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds, int maxCaptchaStoreSize, int captchaStoreLoadBeforeGarbageCollection) {
        super(captchaStore, captchaEngine, minGuarantedStorageDelayInSeconds, maxCaptchaStoreSize, captchaStoreLoadBeforeGarbageCollection);
    }
    /**
     * 功能描述：仓库中是否有与 Seesionid 匹配的验证码
     *
     * @author cakin
     * @date 2020/5/31
     * @param id sessionid
     * @param userCaptchaResponse 验证码
     * @return boolean
     */
    public boolean hasCapcha(String id, String userCaptchaResponse) {
        return store.getCaptcha(id).validateResponse(userCaptchaResponse);
    }
}
